//
//  UserEarningRecordCell.m
//  CheekiOS
//
//  Created by mac on 2017/6/22.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "UserEarningRecordCell.h"

@interface UserEarningRecordCell ()
@property (nonatomic, strong) UILabel *nameLab;
@property (nonatomic, strong) UILabel *giftLab;
@property (nonatomic, strong) UILabel *timeLab;

@property (nonatomic, strong) UILabel *linLab;
@end

@implementation UserEarningRecordCell

+(instancetype)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
    static NSString *UserEarningRecordCellIdent = @"UserEarningRecordCellIdent";
    UserEarningRecordCell *cell = [tableView dequeueReusableCellWithIdentifier:UserEarningRecordCellIdent];
    if (!cell) {
        cell = [[UserEarningRecordCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:UserEarningRecordCellIdent];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    return cell;
    
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.nameLab = [[UILabel alloc] init];
        self.nameLab.font = FontP(15);
        self.nameLab.textAlignment = NSTextAlignmentLeft;
        self.nameLab.textColor = ColorI(0x5978b6);
        [self addSubview:self.nameLab];
        
        self.giftLab = [[UILabel alloc] init];
        self.giftLab.font = FontP(12);
        self.giftLab.textAlignment = NSTextAlignmentLeft;
        self.giftLab.textColor = [UIColor blackColor];
        [self addSubview:self.giftLab];
        
        self.timeLab = [[UILabel alloc] init];
        self.timeLab.font = FontP(12);
        self.timeLab.textAlignment = NSTextAlignmentLeft;
        self.timeLab.textColor = RGB(220, 220, 220);
        [self addSubview:self.timeLab];
        

        
        self.linLab  = [[UILabel alloc] init];
        self.linLab.backgroundColor = TheLinColor;
        [self addSubview:self.linLab];

        
    }
    return self;
}

-(void)setModel:(UserCharm1ListModel *)model{
    
    if ([model.type isEqualToString:@"1"]) {
        if ([model.status isEqualToString:@"1"]) {
            self.nameLab.text = @"提现进行";
            self.giftLab.text = [NSString stringWithFormat:@"使用%@魅力值，提现%@元",model.charm1,model.cost];

            
        }else if ([model.status isEqualToString:@"2"]){
            self.nameLab.text = @"提现成功";
            self.giftLab.text = [NSString stringWithFormat:@"使用%@魅力值，提现%@元",model.charm1,model.cost];


        }else{
            self.nameLab.text = @"提现失败";
            self.giftLab.text = @"该次提现失败";
        }

    }else if ([model.type isEqualToString:@"2"]){
        self.nameLab.text = @"收到礼物";
        self.giftLab.text = [NSString stringWithFormat:@"收到%@个%@，价值%@魅力值",model.giftCount,model.giftName,model.charm1];
    
    }else{
        self.nameLab.text = @"兑换成功";
        self.giftLab.text = [NSString stringWithFormat:@"使用%@魅力值兑换%@钻石",model.charm1,model.charm];

    }
    
    
    self.timeLab.text = model.createTime;
    
    
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self);
        make.height.mas_equalTo(30);
    }];
    
    
    [self.giftLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLab.mas_right).offset(15);
        make.top.equalTo(self);
        make.height.mas_equalTo(30);
    }];
    
    [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self.nameLab.mas_bottom);
        make.height.mas_equalTo(30);
    }];
    

    
    [self.linLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.timeLab.mas_bottom).offset(3);
        make.right.width.equalTo(self);
        make.height.mas_equalTo(1);
    }];


}

@end
